﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QD.Utill;
using QD.Snapshot.Core.Config;
using QD.Snapshot.Core.Model;
using Newtonsoft.Json;

namespace QD.Snapshot.Core.BLL
{
    public class UrlDomain
    {
        public static Dictionary<string, string> Domain { get; private set; }

        public static void Init()
        {
            HttpRequest http = new HttpRequest();
            try
            {
                string html = http.Requset(string.Format("{0}api/snap/ajax.ashx?action=GetListBySite", SiteConfig.ApiDomain));

                JsonModel json = JsonConvert.DeserializeObject<JsonModel>(html);

                if (json != null && json.Data != null)
                    Domain = JsonConvert.DeserializeObject<Dictionary<string, string>>(json.Data.ToString());
            }
            catch (Exception ex)
            {
                Domain = null;
                Pigeon.Utility.Log.Write(string.Format("error_{0}.log", DateTime.Now.ToString("yyyyMMdd")), string.Format("加载网址平台错误:", ex.Message));
            }
        }

    }
}
